﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Citi.ReportManager.Domain;

namespace Citi.ReportManager.WebUi.Models
{
    public class ReportFolderModel
    {
        public int Id { get; set; }
        public int CategoryId { get; set; }
        public CategoryModel Category { get; set; }
        public string FolderPath { get; set; }
        public bool IncludeDirectories { get; set; }
        public short DaysToBackup { get; set; }
        public bool CanConvertToXlsb { get; set; }
        public bool SeparateInFolder { get; set; }
        public bool MoveFilePermanently { get; set; }

        public ReportFolderModel CreateModel(ReportFolder domain)
        {
            return new ReportFolderModel
            {
                CanConvertToXlsb = domain.CanConvertToXlsb,
                Category = new CategoryModel().CreateModel(domain.Category),
                CategoryId = domain.CategoryId,
                DaysToBackup = domain.DaysToBackup,
                FolderPath = domain.FolderPath,
                Id = domain.Id,
                IncludeDirectories = domain.IncludeDirectories,
                //SeparateInFolder = domain.SeparateInFolder,
                MoveFilePermanently = domain.MoveFilePermanently
            };
        }

        public IEnumerable<ReportFolderModel> CreateModel(IEnumerable<ReportFolder> domain)
        {
            return domain.Select(CreateModel);
        }

        public ReportFolder CreateDomain(ReportFolderModel model)
        {
            return new ReportFolder
            {
                CanConvertToXlsb = model.CanConvertToXlsb,
                //Category = new CategoryModel().CreateDomain(model.Category),
                CategoryId = model.CategoryId,
                DaysToBackup = model.DaysToBackup,
                FolderPath = model.FolderPath,
                Id = model.Id,
                IncludeDirectories = model.IncludeDirectories,
                //SeparateInFolder = model.SeparateInFolder,
                MoveFilePermanently = model.MoveFilePermanently
            };
        }

        public IEnumerable<ReportFolder> CreateDomain(IEnumerable<ReportFolderModel> model)
        {
            return model.Select(CreateDomain);
        }
    }
}